<?php

	
// Screen
use Fox\Common\Localization\City;
use Fox\Html\Screen;
$screen = new Screen("sSelect","extract");
$block = new Block("bSelect","Select Cities");
$block->add(new Input("city"));
$block->add(new Input("dbcnt",true,100));
$screen->add($block);

if($screen->posted())
{
	$inputs = $screen->get();
	if(!Xview::instance()->errors())
	{
		$fragments[] = $block->city;
		$fragment = Fox\Dao\SqlFragment::combine($fragments);
		// Load Cities
		$finder = new City();
		$cities = $finder->find($fragment,null,null,$inputs['dbcnt']);
	}
}
echo $screen->display();
exit;

	global $xview;
// Load Cities

	
	// Allocine
	$i = 450;
	$ilink = 'http://www.allocine.fr/series/ficheserie_gen_cserie='.$i.'.html';
	$html = file_get_html($ilink);
	var_dump($html);
	// Find all links 
	foreach($html->find('.rubric') as $key => $elm)
	{
		if($key == 0)
		{
			// First Serie Name
			$s_head['sname'] = utf8_decode(trim($elm->plaintext));
		}
		elseif($key == 1)
		{
			// Fiche Serie
			foreach($elm->find('.vmargin20t') as $tabix => $selm )
			{
				if($tabix == 0)
				{
					// Liste des acteurs
					foreach($selm->find('a') as $actor)
					{
						if(preg_match("/personne/",$actor->href))
						{
							// Actor Id
							$actid = substr(utf8_decode($actor->href),38,-5);
							 $s_actor['actorid'] = $s_actor['extid'] = $actid;
							// Actor Name
							$s_actor['name1'] = $actor->title;
							$streets[$actid] = $s_actor;
						}
					}
				}
				elseif($tabix == 1)
				{
					
					echo utf8_decode($selm->plaintext). '<br><br>';
				}
			}
			// Synopsis
			foreach($elm->find('div[id=cettesemaine_suite2]') as $selm )
				$s_head['descr'] = substr(utf8_decode(trim($selm->plaintext)),11);
		}
		else
			break;
	}
//	var_dump($s_head);
	exit;
	// Save Actors
	if(is_array($streets))
	{
		foreach($streets as $actor)
		{
			
			$sodbi->insert('actors',$actor);
		}
	}
?>